
**************************************************************
* CROWDFUNDING
* FIGURES
* CODE BY: ERIK ANSINK
**************************************************************



**************************************************************
* FIGURES
**************************************************************


* Figure 1
use "tempdata/login.dta", clear
preserve
drop if exp==1
gen hourfromstart = secfromstart/3600
keep hourfromstart
sort hourfromstart
drop if hourfromstart==.
outfile using figuredata/fig1.txt, replace
restore


* Figure 1A
use "tempdata/login.dta", clear
preserve
drop if exp==0
gen hourfromstart = secfromstart/3600
keep hourfromstart
sort hourfromstart
drop if hourfromstart==.
outfile using figuredata/fig1A.txt, replace
restore


* Figure 2
use "tempdata/login.dta", clear
preserve
drop if exp==1
keep contribution
sort contribution
drop if contribution==.
outfile using figuredata/fig2.txt, replace
restore


* Figure 2A
use "tempdata/login.dta", clear
preserve
drop if exp==0
keep contribution
sort contribution
drop if contribution==.
outfile using figuredata/fig2A.txt, replace
restore


* Figure 3
use "tempdata/groupproject.dta", clear
drop if exp==1
preserve
keep overinvestment
drop if overinvestment==.
outfile using figuredata/fig3part1.txt, replace
restore
preserve
keep overinvestment could
replace could=overinvestment if could==1
keep could
drop if could==. | could==0
outfile using figuredata/fig3part2.txt, replace
restore


* Figure 3A
use "tempdata/groupproject.dta", clear
drop if exp==0
preserve
keep overinvestment
drop if overinvestment==.
outfile using figuredata/fig3Apart1.txt, replace
restore
preserve
keep overinvestment could
replace could=overinvestment if could==1
keep could
drop if could==. | could==0
outfile using figuredata/fig3Apart2.txt, replace
restore


* Figure 4
use "tempdata/participant.dta", clear
preserve
drop if exp==1
keep participantpayoff
sort participantpayoff
drop if participantpayoff==.
outfile using figuredata/fig4.txt, replace
restore


* Figure 5
use "tempdata/treatmentproject.dta", clear
preserve
	drop if exp==1
	sort treatmentID projectID
	keep treatmentID treatmentdescription projectID avgtreatmentprojectsuccess
	rename avgtreatmentprojectsuccess mean
	forval i = 1(1)6 {
		gen mean`i' = mean if projectID == `i'
	}
	collapse (first) treatmentdescription (max) mean1 mean2 mean3 mean4 mean5 mean6, by (treatmentID)
	drop treatmentID
	outfile using figuredata/fig5part1.txt, replace noquote wide
restore
preserve
	drop if exp==1
	sort treatmentID projectID
	keep treatmentID treatmentdescription projectID avgtreatmentprojectcontributions
	rename avgtreatmentprojectcontributions mean
	forval i = 1(1)6 {
		gen mean`i' = mean if projectID == `i'
	}
	collapse (first) treatmentdescription (max) mean1 mean2 mean3 mean4 mean5 mean6, by (treatmentID)
	drop treatmentID
	outfile using figuredata/fig5part2.txt, replace noquote wide
restore



* Figure 6
use "tempdata/groupproject.dta", clear
replace projectsuccess=0 if projectsuccess==.
preserve
	drop if exp==1
	keep if projectsuccess==0
	keep cont5hrs
	outfile using figuredata/fig6-5hrs0.txt, replace
restore
preserve
	keep if projectsuccess==1
	keep cont5hrs
	outfile using figuredata/fig6-5hrs1.txt, replace
restore
preserve
	keep if projectsuccess==0
	keep cont10hrs
	outfile using figuredata/fig6-10hrs0.txt, replace
restore
preserve
	keep if projectsuccess==1
	keep cont10hrs
	outfile using figuredata/fig6-10hrs1.txt, replace
restore
preserve
	keep if projectsuccess==0
	keep cont15hrs
	outfile using figuredata/fig6-15hrs0.txt, replace
restore
preserve
	keep if projectsuccess==1
	keep cont15hrs
	outfile using figuredata/fig6-15hrs1.txt, replace
restore



* Figure 7
use "tempdata/treatmentproject.dta", clear
preserve
	drop if exp==0	
	sort treatmentID projectID
	keep treatmentID treatmentdescription projectID avgtreatmentprojectsuccess
	rename avgtreatmentprojectsuccess mean
	forval i = 1(1)3 {
		gen mean`i' = mean if projectID == `i'
	}
	collapse (first) treatmentdescription (max) mean1 mean2 mean3, by (treatmentID)
	drop treatmentID
	outfile using figuredata/fig7part1.txt, replace noquote wide
restore
preserve
	drop if exp==0
	sort treatmentID projectID
	keep treatmentID treatmentdescription projectID avgtreatmentprojectcontributions
	rename avgtreatmentprojectcontributions mean
	forval i = 1(1)3 {
		gen mean`i' = mean if projectID == `i'
	}
	collapse (first) treatmentdescription (max) mean1 mean2 mean3, by (treatmentID)
	drop treatmentID
	outfile using figuredata/fig7part2.txt, replace noquote wide
restore






clear
